﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for BenhNhanBLL
/// </summary>
public class BenhNhanBLL
{
    DataService db = new DataService();

    public List<BenhNhan> GetAllBenhNhan()
    {
        List<BenhNhan> bn = new List<BenhNhan>();
        DataTable dt = db.GetData("select * from BenhNhan");
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow row in dt.Rows)
            {
                bn.Add(Chuyen1Dong(row));
            }
            return bn;
        }
        return null;
    }


    public void InsertBenhNhan()
    {

    }






    private BenhNhan Chuyen1Dong(DataRow dong)
    {
        BenhNhan bn = new BenhNhan();
        bn.HoTenBenhNhan = (string)dong["HoTenBenhNhan"];
        bn.NgaySinh = (DateTime)dong["NgaySinh"];
        bn.GioiTinh = (bool)dong["GioiTinh"];
        bn.DiaChi = (string)dong["DiaChi"];
        bn.DienThoai = (string)dong["DienThoai"];
        bn.NoiLamViec = (string)dong["NoiLamViec"];
        bn.MaDoiTuong = (string)dong["MaDoiTuong"];
        bn.SoBHYT = (string)dong["SoBHYT"];
        bn.NgayBD_BHYT = (DateTime)dong["NgayBD_BHYT"];
        bn.NgayKT_BHYT = (DateTime)dong["NgayKT_BHYT"];
        bn.MaQuocTich = (string)dong["MaQuocTich"];
        bn.MaTinhThanh = (string)dong["MaTinhThanh"];
        bn.MaQuanHuyen = (string)dong["MaQuanHuyen"];
        bn.MaPhuongXa = (string)dong["MaPhuongXa"];
        bn.MaDanToc = (string)dong["MaDanToc"];
        bn.MaNgheNghiep = (string)dong["MaNgheNghiep"];
        bn.HoTenNguoiNha = (string)dong["HoTenNguoiNha"];
        bn.NgheNghiepNguoiNha = (string)dong["NgheNghiepNguoiNha"];
        bn.TenNgheNghiepNguoiNha = (string)dong["TenNgheNghiepNguoiNha"];
        bn.DienThoaiNguoiNha = (string)dong["DienThoaiNguoiNha"];
        bn.DiaChiNguoiNha = (string)dong["DiaChiNguoiNha"];
        bn.HoTenCha = (string)dong["HoTenCha"];
        bn.NgheNghiepCha = (string)dong["NgheNghiepCha"];
        bn.TenNgheNghiepCha = (string)dong["TenNgheNghiepCha"];
        bn.DienThoaiCha = (string)dong["DienThoaiCha"];
        bn.HoTenMe = (string)dong["HoTenMe"];
        bn.NgheNghiepMe = (string)dong["NgheNghiepMe"];
        bn.TenNgheNghiepMe = (string)dong["TenNgheNghiepMe"];
        bn.DienThoaiMe = (string)dong["DienThoaiMe"];

        return bn;
    }
}